// unary_negate example
#include <algorithm>  // std::count_if
#include <functional> // std::unary_negate
#include <iostream>   // std::cout

struct IsOdd {
  bool operator()(const int &x) const { return x % 2 == 1; }
  typedef int argument_type;
} IsOdd_obj;

int main() {
  std::unary_negate<IsOdd> IsEven_obj(IsOdd_obj);
  int values[] = {1, 2, 3, 4, 5};
  int cx;
  cx = std::count_if(values, values + 5, IsEven_obj);
  std::cout << "There are " << cx << " elements with even values.\n";
  return 0;
}
